package com.cet.algorithm.考试;

/**
 * @program: cet-practice
 * @description:
 * @author: 陈恩涛
 * @create: 2023-04-01 16:34
 **/
public class Solution1 {

    public static void main(String[] args) {

        int[] stack = {1, 2, 3, 4, 5};
        for (int i = 0; i < reverseStack(stack).length; i++) {
            System.out.println(stack[i]);
        }
    }

    public static int[] reverseStack(int[] sta) {
        reverseStack(sta,0, sta.length - 1);
        return sta;
    }

    public static void reverseStack(int[] sta, int first, int last) {
        if (first < last) {
            int temp = sta[first];
            sta[first] = sta[last];
            sta[last] = temp;
            reverseStack(sta,first + 1, last - 1);
        }
    }
}
